<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>电影编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/index.css">
    <link href="${path}/css/updateMovie.css" rel="stylesheet" type="text/css">
    <script src="${path}/js/jquery-3.6.4.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/index.js"></script>
</head>
<body>
<%
    String id=request.getParameter("id");
%>
<div class="action  divaction">
    <hr>
    <form method="post" action="${path}/UpdateMovieServlet?prom=updMovie&movie_id=${movie.movie_id}" enctype="multipart/form-data">
<c:choose>
    <c:when test="${empty movie}">
        <script>
            window.location="${path}/UpdateMovieServlet?prom=selMovie&movie_id=<%=id%>";
        </script>
    </c:when>
    <c:otherwise>

        <div class="b2">
            <ul>
                <li>
                    <div class="a2">
                        <img id="moviePirture"  src="${path}/images/moviePicture/${movie.movie_picture}" >
                    </div>

                    <input type="button" value="选择文件" id="buttonx"><input id="file" type="file" onchange="handleFiles(/*this.files*/)" multiple="multiple" name="movie_picture" value="${movie.movie_picture}">
                </li>
                <li>
                    <p>
                    <div class="a3">
                        <span class="b1">电影名称-中文</span>
                        <input type="text" placeholder="请输入电影名" class="a4" name="movie_cn_name" value="${movie.movie_cn_name}"/>
                    </div>
                    </p>
                </li>
                <li>
                    <p>
                    <div class="a3">
                        <span class="b1">电影名称-外语</span>
                        <input type="text" placeholder="请输入电影名" class="a4" name="movie_fg_name" value="${movie.movie_fg_name}"/>
                    </div>
                    </p>
                </li>
                <li>

                    <div class="a3">
                        <span class="b1">电影类型</span>
                    </div>
                    <input type="text" class="a4" name="movie_type" value="${movie.movie_type}"readonly="readonly"/>

                </li>
                <li>

                    <div class="a3">
                        <span class="b1">电影地区</span>
                        <input type="text" placeholder="中国大陆" class="a4" name="movie_country" value="${movie.movie_country}"/>
                    </div>

                </li>
                <li>
                    <p>
                    <div class="a3">
                        <span class="b1">电影导演</span>
                        <input type="text" placeholder="请填写电影导演" class="a4" name="movie_director" value="${movie.movie_director}"/>
                    </div>
                    </p>
                </li>
                <li>
                    <p>
                    <div class="a3">
                        <span class="b1">电影主演</span>
                        <input type="text" placeholder="请填写电影主演" class="a4" name="movie_actor" value="${movie.movie_actor}"/>
                    </div>
                    </p>
                </li>
                <li>
                    <p>
                    <div class="a3">
                        <span class="b1">电影片长</span>
                        <input type="text" placeholder="请填写电影片长(单位:分钟)" class="a4" name="movie_duration" value="${movie.movie_duration}"/>
                    </div>
                    </p>
                </li>
                <li>
                    <p>
                    <div class="a3">
                        <span class="b1">上映时间</span>
                        <input type="text" placeholder="请输入电影上映日期" class="a4" name="movie_releaseDate" value="${movie.movie_releaseDate}"/>
                    </div>
                    </p>
                </li>
                <li>
                    是否上映:
                    <c:if test="${movie.movie_state=='1'}">
                        <input type="radio" name="movie_state" value="1" checked>在线
                        <input type="radio" name="movie_state" value="2">预售
                        <input type="radio" name="movie_state" value="3">下架
                    </c:if>
                    <c:if test="${movie.movie_state=='2'}">
                        <input type="radio" name="movie_state" value="1" >在线
                        <input type="radio" name="movie_state" value="2" checked>预售
                        <input type="radio" name="movie_state" value="3" >下架
                    </c:if>
                    <c:if test="${movie.movie_state=='3'}">
                        <input type="radio" name="movie_state" value="1" >在线
                        <input type="radio" name="movie_state" value="2" >预售
                        <input type="radio" name="movie_state" value="3" checked>下架
                    </c:if>
                </li>
                <li>
                    <input type="submit" value="修改" class="a9">
                    <input type="button" value="返回" class="a9" onclick="javascript:window.location='inquireMovie.jsp'">
                </li>
            </ul>
        </div>
    </form>
    </c:otherwise>
    </c:choose>
</div>
<script>

    function handleFiles() {
        //获取文件名称
        var url=document.getElementById('file').files[0].name;
        $("#moviePirture").attr("src","${path}/images/moviePicture/"+url);
        //获取文件全部路径
        var urlPath=document.getElementById('file').value;
    };
   /*
   function handleFiles(files){
       if(files.length){
           let file = files[0];
           let reader = new FileReader();
           reader.onload = function(){
               document.getElementById('text').innerHTML = this.result;
           };
           reader.readAsText(file);
       }
   }*/
</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>

